package org.dromara.northstar.gateway.okx;

import org.dromara.northstar.common.constant.ChannelType;
import org.dromara.northstar.gateway.GatewayMetaProvider;
import org.dromara.northstar.gateway.IMarketCenter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Order(0)    // 加载顺序需要显式声明，否则会最后才被加载，从而导致加载网关与模组时报异常
@Component
public class OkxLoader implements CommandLineRunner {

    @Autowired
    private IMarketCenter mktCenter;    //

    @Autowired
    private GatewayMetaProvider gatewayMetaProvider;

    @Autowired
    private OkxGatewayFactory okxFactory;

    @Autowired
    private OkxContractProvider okxContractProvider;

    @Override
    public void run(String... args) throws Exception {
        gatewayMetaProvider.add(ChannelType.OKX, new OkxGatewaySettings(), okxFactory);
        // 加载OKX增加合约定义
        //mktCenter.addDefinitions(okxContractProvider.get());
        // 注册合约
        //binanceContractProvider.loadContractOptions();

        mktCenter.loadContractGroup(ChannelType.OKX);
    }
}
